<template>
  <div class="container">
  <FmTable ref="fmTable" url="/process/flowable" id="taskId" tableName="task" listapiurl="finishedList" :columns="columns"
           :toolbar="['del']">
    <template #procDefVersion="scope">
      <el-tag size="small">v{{ scope.row.procDefVersion }}</el-tag>
    </template>

    <template #opt="scope">
      <el-button
          size="small"
          type="primary"
          link
          icon="Tickets"
          @click="handleFlowRecord(scope.row)"
      >流转记录</el-button>
      <el-button
          size="small"
          type="primary"
          link
          icon="Refresh"
          @click="handleRevoke(scope.row)"
      >撤回
      </el-button>
    </template>
  </FmTable>
  </div>
</template>
<script setup lang="ts">
import {useRouter} from "vue-router";
import {saveorUpadateDate} from "@/api/index";
import {ElMessage, ElMessageBox} from "element-plus";
import {ref} from "vue";
let router=useRouter()
const columns = [
  {
    "label": "任务编号",//标签名称
    "index": "taskId",//数据库索引
    "rules": [
      {required: true, message: "请输入主键", trigger: "blur",},
    ],//值规则
    "search": true,//是否是搜索表单
    "dataType": "text",//值值类型默认字符类型
    "addable": false
  },
  {
    "label": "流程名称",//标签名称
    "index": "procDefName",//数据库索引
    "rules": [
      {required: true, message: "请输入主键", trigger: "blur",},
    ],//值规则
    "search": true,//是否是搜索表单
    "dataType": "text",//值值类型默认字符类型
    "addable": false
  },
  {
    "label": "任务节点",//标签名称
    "index": "taskName",//数据库索引
    "rules": [
      {required: true, message: "请输入主键", trigger: "blur",},
    ],//值规则
    "dataType": "text",//值值类型默认字符类型
    "addable": false
  },
  {
    "label": "流程发起人",//标签名称
    "index": "startUserName",//数据库索引
    "rules": [
      {required: true, message: "请输入主键", trigger: "blur",},
    ],//值规则
    "dataType": "text",//值值类型默认字符类型
    "addable": false
  },
  {
    "label": "接收时间",//标签名称
    "index": "createTime",//数据库索引
    "rules": [
      {required: true, message: "请输入主键", trigger: "blur",},
    ],//值规则
    "dataType": "text",//值值类型默认字符类型
    "addable": false
  },
  {
    "label": "审批时间",//标签名称
    "index": "finishTime",//数据库索引
    "rules": [
      {required: true, message: "请输入主键", trigger: "blur",},
    ],//值规则
    "dataType": "text",//值值类型默认字符类型
    "addable": false
  },
  {
    "label": "耗时",//标签名称
    "index": "duration",//数据库索引
    "rules": [
      {required: true, message: "请输入主键", trigger: "blur",},
    ],//值规则
    "dataType": "text",//值值类型默认字符类型
    "addable": false
  },
  {
    "type": "opt",//普通行，字典行，自定义行
    "label": "操作",//标签名称
    "index": "opt",//数据库索引
    "rules": [],//值规则
    "width": 190,
    "dataType": "text",//值值类型默认字符类型
  }
]
let fmTable = ref()
const handleFlowRecord=(row:any)=>{
  router.push({ path: '/admin/task/finishedprocessdeatil',
    query: {
      procInsId: row.procInsId,
      deployId: row.deployId,
      taskId: row.taskId,
    }})
}
/** 撤回任务 */
const handleRevoke=(row:any)=>{
  const params = {
    instanceId: row.procInsId
  }
  saveorUpadateDate("/process/flowable/task/revokeProcess",params).then( res => {
    ElMessage.success(res);
    fmTable.value.readyGetData()
  })
}


</script>